// import axios from "axios";
import http from "@/utils/http";

export default {
  namespaced: true,

  state: {
    quotaList: []
  },

  mutations: {
    SETQUOTALIST(state, list) {
      var _list=JSON.parse(JSON.stringify(list))
      for(var i = 0; i < list[1].length; i++) {//彩种
        //do something
        for(var k = 0; k < list[1][i].bet_sign.length; k++) {//投注分组
          //do something
          _list[1][i].bet_sign[k].room_lottery_odds=[];
          for(var n = 0; n < list[1][i].bet_sign[k].room_lottery_odds.length; n++) {//投注赔率
            //do something
            if(!_list[1][i].bet_sign[k].room_lottery_odds[Math.floor(n/3)]){
              _list[1][i].bet_sign[k].room_lottery_odds[Math.floor(n/3)]=[]
            }
            _list[1][i].bet_sign[k].room_lottery_odds[Math.floor(n/3)].push(list[1][i].bet_sign[k].room_lottery_odds[n])
          };
        };
      };
      // for(var item in list[1]) {
      //   //do something
      //   for (var bet_sign in item.bet_sign){
      //     for (var room_lottery_odd in bet_sign.room_lottery_odds){
      //       bet_sign.room_lottery_odds.push(1);
      //     }
      //   }
      // };
      console.log(_list)
      state.quotaList = _list;
    }
  },

  actions: {
    getQuotaList({ commit }) {
      let token=sessionStorage.getItem('token')
      http
        .post(
          `api/rule/lottery/get_select?token=${token}`
        )
        .then(response => {
          let res = response.data.list;
          commit("SETQUOTALIST", res);
        });
    },
    saveQuotaList({ commit }) {
      http.post(
        "api/rule/lottery/get_select?token=2Q3ntNqyo5eaLmXITABb"
      )
        .then(response => {
          let res = response.data.list;
          commit("SETQUOTALIST", res);
        });
    }
  }
};
